using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Text;
using DTO.PO;

namespace DAO.PO
{
    public class BatchDAO
    {
        //insert POBatch man` hinh` 2
        public void InsertPOBatch(Batch batch)
        {
            DataProvider provider = new DataProvider();
            provider.Open();
            string command = "insert into PO_Batch(Status, QtyTotal, ReceiptNumber) values ("
                + batch.Status + "," + batch.QtyTotal + "," + batch.ReceiptNumber +  ")";

            provider.ExcuteNonQuery(command);
            provider.Close();
        }

        // man` hinh` 3
        public void UpdateStatus(int poBatchNumber, char status)
        {
            DataProvider provider = new DataProvider();
            provider.Open();
            string command = "update PO_Batch set Status = " + status + "where POBatchNumber = " + poBatchNumber;

            provider.ExcuteNonQuery(command);
            provider.Close();
        }

        // man` hinh` 4
        public bool GetBatch(int poBatchNumber)
        {
            DataProvider provider = new DataProvider();
            provider.Open();
            string command = "select POBatchNumber from PO_Batch where POBatchNumber = " + poBatchNumber;

            SqlDataReader reader = provider.ExecuteReader(command);
            bool check = reader.Read();
            reader.Close();
            provider.Close();

            return check;
        }
    }
}
